I am trying to build a form where I can scroll through instances of obsterms chronologically. The big issue is if there has been more than 1 value entered on a single date to one obsterm. In other words, if a patient sees Dr. A and Dr. B on 6/1/2015 and both Dr. A and Dr. B enter values into the obsterm "HPI INFO 1", what I would like to be able to do is create a form where I can scroll through all instances of HPI INFO 1 for that patient and be alerted if there is more than 1 value for a specific date and have it allow me to choose which instance I would like to use. Any ideas?? Thanks in advance!
Use LIST_OBS to get all the signed values of your obsterm.
.
local oList = LIST_OBS('HPI INFO 1','signed','delimited','value')
.
the list that gets returned into oList separates each separate value-row with "|"
and separates each value field within a row with "^"
.
local oArray = getfield(oList,"|","")
local i=0, imax=size(oArray)
local aRow
.
for i=1, i<=imax, i=i+1 do
aRow=getfield(oArray[i],"^","")
// Now you have access to all the values - see below
thisVal = aRow[1]
thisDate = aRow[2]
thisTime = aRow[3]
thisSignedBy = aRow[4]
etc....
endfor
.
[Field #] / Description ( Example )
[1] / Observation Value ( 69 )
[2] / Observation Date ( 01/01/2003 )
[3] / Observation Time ( 5:05:00 PM )
[4] / Signing User ( Jerry Lewis, M.D. / Note. Blank if unsigned)
[5] / Entering User ( Dean Martin )
[6] / Flags ( AA )
[7] / Comment ( Measured with ruler )
[8] / State ( F )
[9] / Location of Care ( Eastside )
[10] / Document Type ( Phone Note )
[11] / Visible Document ID ( 23 )
.
- Beverly
Thanks Beverly,
I have that subarray and I can return those specific values and scroll through them chronologically. I am displaying that in a data display. However, what I would like to have is a watcher expression and a second data display. If there is more than 1 value for a specific date, I would like the second value to be displayed in the second data field.
So if you are looping through all values of oList for obsterm "HPI INFO 1",
keep track of the previous date while looping.
Compare current to previous:
if DURATIONDAYS(prevdate, thisdate) = 0
then you have found an instance of the same obsterm stored multiple times on the same date.
.
As you loop, you could build a result string to later parse when populating the data displays,
where each "row" identifies ALL values for a single date.
Example of final result string:
result =
04/15/2015^value1~time1~signedby1
|03/15/2015^value1~time1~signedby1&value2~time2~signedby2
|10/15/2014^value1~time1~signedby1
.
Then when looping through to populate your data display 1,
//Get all rows (|) of dates
dateAry = getfield(result,"|","")
.
// for each date, get its groups of values
for i=1, i<=size(dateAry), i=i+1 do
valueAry = getfield(dateAry[i],"^","")
thisdate = valueAry[1]
.
fieldAry = getfield(valueAry[2],"&","")
//for each group of values (k), get its fields
for k=1, k<=size(fieldAry), k=k+1 do
aRow = getfield(fieldAry[k],"~","")
if k==1 then
//populate data display 1
document.display1_date = thisDate
document.display1_value =aRow[1]
document.display1_time = aRow[2]
document.display1_signedby = aRow[3]
else if k==2 then
//populate data display 2
document.display2_date = thisDate
document.display2_value =aRow[1]
document.display2_time = aRow[2]
document.display2_signedby = aRow[3]
endif // data display 2
endif // data display 1
endfor // k loop thru values
endfor // i loop thru dates
.
The above is off the top of my head, but that is the concept...
.
- Beverly
awesome that is great advice! I have been trying to use the match data symbol but using the durationdays seems much more economical. And building the result string; had not thought of that. Thank you so much, I will give this a try!