Date: Fri, 29 Mar 2024 22:17:05 +1000 (AEST) Message-ID: <2128459880.1182.1711714625346@dsp-kbconf-01.ad.medicalobjects.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_1181_677928103.1711714625339" ------=_Part_1181_677928103.1711714625339 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
This tutorial will build on the GELLO coding introduced last time, with = the calculation of an age for our test patient, the adding of clinical data= to the test file, the importing of that data into the editor and then look= ing at the implies method for the first time.
Type or cut and past the following code:
Context HL7_v2_VMR_V1::SinglePatient patient.dob
Run it and choose the firstTest.xml patient file from the= last tutorial:
We can see the date of birth is the 21st June 1955, but lets now calcula= te the patient's age. Assign the retrieved date of birth to be a local vari= able so that we can calculate with it:
Let dob =3D patient.dob
Compile this and note the error message (note again this will run howeve= r). Yes, GELLO is strongly typed and the editor is suggesting the type for = the local variable, so add it in. The line becomes:
Let dob: TS =3D patient.dob
We don't worry about the second message saying there is no final express= ion as we can say that at the end - this returns what it is we actually wan= t - i.e. the age; and we will get to that. So here is where we are up to:= p>
Notice that it says _Result_ is null, again this is bec=
ause we have no final expression line as yet.
Add in this code which includes the required final expression:
let ageInSeconds: PQ =3D factory.TS('today') - dob Let ageInYrs: PQ =3D ageInSeconds.convert('yr') ageInYrs
Don't worry too much about the actual code here, but it involves the use= of the factory class and a method that converts units.
Unfold on the _Result_ and notice that this Physical Qu= antity (PQ) typed result has both a unit and a value:
It is best to use PQ variables in GELLO instead of further getting the v= alue out as a Real typed value, eg for laboratory results, as sometimes uni= ts change with lab tests and you don't want to be caught out with 'apples a= nd oranges'! [eg think about the two following measurements: 2 cm and 0.787= 4016 inches. They are the same measurement in fact; but if we just wrote co= de using the values, 2 does not equate to 0.7874016]
The good thing about using PQs is that you can perform mathematical operat=
ions on them. The full list of methods the class understands can be seen in=
the editor, by looking in the Model Explorer like we did for the CD type:<=
/p>
------------------------------------------------------------------------= --------------------
Ok, next we will move on to how we load up our test data for a GELLO editi=
ng session. This is easily done by opening the Model Explorer pane (fold up=
the PQ and the iso_21090_datatype package if you are still there) and unfo=
lding on the HL7_v2_VMR_V1 package again. Go down to the SinglePati=
ent node and right click on this. Choose the Read Test Dat=
a for class option and then choose our firstTest.xml file. This lo=
ads up the instance data for the model, which can be viewed in the Data Exp=
lorer - so far we have patient class data only.
--------------------------------------------------------------------------=
-------------------
Lets add some allergy data to our firstTest.xml file.
Do this by inserting all of this xml above the final line in firstTe= st.xml and rename it secondTest.xml :
<allergies>
<allergenType code=3D"373873005"
codeSystem=3D"2.16.840.1.113883.6.96" codeSystemName=3D"SNOMED-CT">
<displayName value =3D "pharmaceutical / biologic = product" />
</allergenType>
<allergenCode code=3D"111088007"
codeSystem=3D"2.16.840.1.113883.6.96" codeSystemName=3D"SNOMED-CT">
<displayName value =3D "latex (product)" />
</allergenCode>
<allergySeverity code=3D"24484000"
codeSystem=3D"2.16.840.1.113883.6.96" codeSystemName=3D"SNOMED-CT">
<displayName value =3D "severe" />
</allergySeverity>
<allergyReaction code=3D"39579001"
codeSystem=3D"2.16.840.1.113883.6.96" codeSystemName=3D"SNOMED-CT">
<displayName value =3D "anaphylaxis" />
</allergyReaction>
<identificationDate value=3D"1980"/>
</allergies>
<allergies>
<allergenType code=3D"373873005"
codeSystem=3D"2.16.840.1.113883.6.96" codeSystemName=3D"SNOMED-CT">
<displayName value =3D "pharmaceutical / biologic = product" />
</allergenType>
<allergenCode code=3D"6369005"
codeSystem=3D"2.16.840.1.113883.6.96" codeSystemName=3D"SNOMED-CT">
<displayName value =3D "penicillin -class of antib= iotic-" />
</allergenCode>
<allergySeverity code=3D"24484000"
codeSystem=3D"2.16.840.1.113883.6.96" codeSystemName=3D"SNOMED-CT">
<displayName value =3D "severe" />
</allergySeverity>
<allergyReaction code=3D"39579001"
codeSystem=3D"2.16.840.1.113883.6.96" codeSystemName=3D"SNOMED-CT">
<displayName value =3D "anaphylaxis" />
</allergyReaction>
<identificationDate value=3D"1980"/>
</allergies>
This data accords with the structure of the allergies class in our VMR.
Now lets move to the editor and think about how we will look for a penic=
illin allergy.
We will use the implies method. This works for data that is of a =
CD data type. We can see from the above data that the allergen=
Code-tagged element has several attributes - namely code,=
codeSystem and codeSystemName. These three are all requi=
red by the ISO21090 standard to make a CD.
So lets load up our new secondTest.xml file into the editor as be=
fore by right clicking on the SinglePatient node in the HL=
7_v2_VMR_V1 package in Model Explorer and bring it in with Read Tes=
t Data for class. Notice the new allergy data in Data Explorer vie=
w. Make sure all attributes are visible and not null. (If things are null t=
here has usually been an error in the syntax of the xml)
Now to the workspace, let's test we can access this data:
Context HL7_v2_VMR_V1::SinglePatient Let patientAllergies: Sequence(Allergy) =3D allergies
We now create a local or temporary variable which will act as parent con= cept for subsumption checking in SNOMED CT, using the implies method.=
add this:
Let penicillinClass_SCT:CD =3D CD{code =3D '6369005', codeSystem =3D '2.16.840.1.113883.= 6.96', codeSystemName =3D'SNOMED-CT' }
So that's the parent concept - the class of penicillins. Our test data h= appens to be at this general level as well - implies works as "equals" as w= ell as "is a child of". The implies method is a collection operator, and al= lergies from the VMR is a sequence; so we use the following syntax and gram= mar - add:
Let hasPenicillinAllergy: Boolean =3D allergies->exists(a| a.allerg= enCode.implies(penicillinClass_SCT).asBoolean()) hasPenicillinAllergy
= Run it:
We can shorten the code needed to create the parent class local variable= - by replacing line 4 with:
Let penicillinClass_SCT: CD =3D factory.CD_SNOMED_CT('6369005')
OK, lets now see what happens if instead of saying the patient is allerg= ic to a= ll penicillins they have been noted to be allergic to a member of that= class, in the EHR; for example amoxicillin ( - normally this would mean th= ey are also allergic to all penicillins):
So we change the data in the xml:
<allergies>
<allergenType code=3D"373873005"
codeSystem=3D"2.16.840.1.113883.6.96" codeSystemName=3D"SNOMED-CT">
<displayName value =3D "pharmaceutical / biologic = product" />
</allergenType>
<allergenCode code=3D"27658006"
codeSystem=3D"2.16.840.1.113883.6.96" codeSystemName=3D"SNOMED-CT">
<displayName value =3D "Amoxicillin" />
</allergenCode>
<allergySeverity code=3D"24484000"
codeSystem=3D"2.16.840.1.113883.6.96" codeSystemName=3D"SNOMED-CT">
<displayName value =3D "severe" />
</allergySeverity>
<allergyReaction code=3D"39579001"
codeSystem=3D"2.16.840.1.113883.6.96" codeSystemName=3D"SNOMED-CT">
<displayName value =3D "anaphylaxis" />
</allergyReaction>
<identificationDate value=3D"1980"/>
</allergies>
Save this as secondTest_amoxicillin_allergy.xml, and run it thi= s time with this data using the Remote execute with xml patient dat= a button:
If you get a http socket error its because you are not hitting our termi= nology service and will need to contact helpdesk and ask for someone in the= Development team to set you up with a newer editor. So you may get a true = result when looking in the Results Explorer:
This demonstrates the real value of a reference terminology such as SNOM= ED CT. If we were using ICD - 9 for example we would have to input a set of= codes for all penicillin antibiotics, here we just use implies to see if o= ur allergen is a penicillin - simple as that.
That completes this tutorial.