QUESTION
How do I figure out which version of the C-Callable Shared Object I am using?
ANSWER
There is no good way because as of this writing, April-2012, the C-Callable Shared Object's API is missing the usual method for retrieving this information.
Instead, to see if your shared object will support a given version, you have to use the errdesc() function, like so:
-------------------------sample code starts
/* declare the functions inside the shared object: */
char * mhdrg();
extern char * errdesc();
int main() {
char * retval;
char * p;
char * a[RETURNED];
char * expected;
int i;
/* call the grouper, store results in reval */
retval = mhdrg(
"f29", /* which DRG version you want */
"/drbd/mnh/src/SWIG", /* path to masks files */
"1", /* discharge status */
"49", /* patient age on admission */
"2", /* patient sex (1=male, 2=female) */
/* ICD DX codes */
//"99679 25041 5859 2767 25051 36904 25061 3371 40290 2859 ",
"71500 Y",
/* ICD procedure codes */
// 0123456012345601234560123456
// "3942 3993 3995 ",
"8134 8135 ",
8, /* length of each ICD DX code */
7 /* length of each ICD procedure code */
);
/* if there was an error, alert the user */
if (retval == NULL) {
printf("M+H grouper argument or environment error: %s\n", errdesc());
exit(-1);
}
/* show the raw return value */
printf("Raw return value from mhdrg:\n%s\n\n",retval);
/* deconstruct return from mhdrg() */
p = strtok(retval,DELIM);
for (i = 0; i < RETURNED && p != NULL; i++) {
a[i] = p;
p = strtok(NULL,DELIM);
}
puts("Deconstructed return value from mhdrg:");
printf("rc=%s, mdc=%s, drg=%s, ovn=%s, weight=",a[0],a[1],a[2],a[3]);
printf("%s, mean=%s, porm=%s\ndesc=%s\ndx flags:%s, px flags: %s\n",a[4],a[5],a[6],a[7],a[8],a[9]);
/* last two return values are bit-strings of which ICD codes were
* used in the grouping
*/
puts("\nSignificant ICD codes:");
p = a[8];
for (i = 0; i < 32 && p[i] != '\000'; i++) {
if (p[i] == '1') {
printf(" * DX code %2d was used\n",(i+1));
}
}
p = a[9];
for (i = 0; i < 32 && p[i] != '\000'; i++) {
if (p[i] == '1') {
printf(" * Proc code %2d was used\n",(i+1));
}
}
exit(0);
}
No comments:
Post a Comment