Esempio n. 1
0
MPerfStationLocation::MPerfStationLocation(
           MString& s,
           const MString& workitemkey
           ) :
  mWorkitemkey(workitemkey)
{
  MString emptyString;

  tableName("perfstationlocation");
  mCodeValue = s.getToken('^', 0);
  insert("codval", mCodeValue);
  if( s.tokenExists('^', 1)) mCodeSchemeDesignator = s.getToken('^',1);
  insert("codschdes", mCodeSchemeDesignator);
  if( s.tokenExists('^', 2)) mCodeMeaning = s.getToken('^',2);
  insert("codmea", mCodeMeaning);
  insert("workitemkey",mWorkitemkey);
}
Esempio n. 2
0
int
MDBImageManager::mergePatient(const MPatient& patient)
{
  MLogClient logClient;
  logClient.log(MLogClient::MLOG_VERBOSE,
		"<no peer>", "MDBImageManager::mergePatient",
		__LINE__,
		"Enter method");

  if (mDBInterface == 0) {
    logClient.logTimeStamp(MLogClient::MLOG_WARN,
		    "Database was not initialized, return from method");
    return 0;
  }

  MCriteriaVector criteria;

  MString s = patient.priorIDList();
  MString priorID = s.getToken('^', 0);

  MCriteria c;
  c.attribute = "patid";
  c.oper      = TBL_EQUAL;
  c.value     = priorID;

  MCriteriaVector cv;
  cv.push_back(c);

  MUpdateVector updateVector;
  MUpdate u;

  u.attribute = "patid";
  u.func      = TBL_SET;
  u.value     = patient.patientID();
  updateVector.push_back(u);

  MStudy study;
  study.patientID(patient.patientID());

  char tmp[512];
  strstream xx(tmp, sizeof(tmp));
  xx << "About to update Study Table: "
	  << "Previous ID (" << priorID << "), "
	  << "New ID: (" << u.value << ")"
	  << '\0';
  logClient.logTimeStamp(MLogClient::MLOG_VERBOSE, tmp);

  mDBInterface->update(study, cv, updateVector);

  // Then delete from patient table.
  mDBInterface->remove(patient, cv);

  // Add the patient if it does not already exist
  this->enter(patient);

  return 0;
}
Esempio n. 3
0
MString
MHL7DomainXlate::getPatientID(MString s, const MString& issuer) const
{
  int index = 0;

  for (index = 0; ; index++) {
    if (s.tokenExists('~', index)) {
      MString x = s.getToken('~', index);
      MString y = x.getToken('^', 3);
      if (issuer == y) {
	MString z = x.getToken('^', 0);
	return z;
      }
    } else {
      cerr << "Could not find patient ID for issuer: " << issuer << endl;
      return "";
    }
  }
}
Esempio n. 4
0
void
MDBImageManager::updateModalitiesInStudy(const MStudy& study,
					 const MString& modality)
{
  MStudyVector v;

  MString uid = study.studyInstanceUID();
  MStudy tempStudy;
  tempStudy.studyInstanceUID(uid);
  MStudyVector::iterator studyStart = mStudyVector.begin();
  MStudyVector::iterator studyEnd = mStudyVector.end();
  mStudyVector.erase(studyStart, studyEnd);
  this->fillStudyVector(tempStudy, v);
  if (v.size() != 1) {
    cerr << "Error when trying to select one MStudy object " << endl;
    cerr << "Study UID = " << uid << endl;
    cerr << "Count = " << v.size() << endl;
    return;
  }

  tempStudy = v[0];
  MString x = tempStudy.modalitiesInStudy();
  bool done = false;
  bool found = false;
  int index = 0;
  for (index = 0; !done; index++) {
    if (!x.tokenExists('+', index))
      break;
    MString s = x.getToken('+', index);
    if (s == modality) {
      found = true;
      done = true;
    }
  }
  if (!found) {
    if (x == "") {
      x = modality;
    } else {
      x = x + "+" + modality;
    }

    tempStudy.modalitiesInStudy(x);
    updateRecord(tempStudy);
  }
}
// virtual
int
MLDispatchOrderPlacerJapanese::acceptADT(MHL7Msg& message, const MString& event)
{
  MLogClient logClient;
  logClient.log(MLogClient::MLOG_CONVERSATION,
		"peer",
		"MLDispatchOrderPlacerJapanese::acceptADT",
		__LINE__,
		MString("Accepting ADT event ")+event);

  MString charSet = message.getValue("MSH", 18, 0);
  MString charSetRep1 = "";
  MString charSetRep2 = "";
  if (charSet.tokenExists('~', 0)) {
    charSetRep1 = charSet.getToken('~', 0);
  }
  if (charSet.tokenExists('~', 1)) {
    charSetRep2 = charSet.getToken('~', 1);
  }

  if (charSetRep1 != "ISO IR6") {
    logClient.log(MLogClient::MLOG_ERROR,
		"peer",
		"MLDispatchOrderPlacerJapanese::acceptADT",
		__LINE__,
		MString("Wrong value in MSH.18 (Character set)") + charSet);
    MHL7Dispatcher::acceptMessageApplicationError(message, event, "AE", "207");
    return 0;
  } else if (charSetRep2 != "ISO IR87") {
    logClient.log(MLogClient::MLOG_ERROR,
		"peer",
		"MLDispatchOrderPlacerJapanese::acceptADT",
		__LINE__,
		MString("Wrong value in MSH.18 (Character set)") + charSet);
    MHL7Dispatcher::acceptMessageApplicationError(message, event, "AE", "207");
    return 0;
  }

  MHL7DomainXlate xLate;
  MPatient patient;
  MVisit   visit;

  xLate.issuer1("ADT1");
  xLate.issuer2("MPI");
  xLate.translateHL7(message, patient);
  xLate.translateHL7(message, visit);

  MString patientString = patient.patientID() + ":" +
		patient.issuerOfPatientID() + ":" +
		patient.patientName();
  logClient.log(MLogClient::MLOG_VERBOSE,
		"peer",
		"MLDispatchOrderPlacerJapanese::acceptADT",
		__LINE__,
		MString("Patient is: ")+patientString);

  processInfo( event, patient, visit);

  // Let the base class see the ADT; it will generate the ACK
  MHL7Dispatcher::acceptADT(message, event);

  return 0;  
}
Esempio n. 6
0
int
MDBImageManager::fillPatientStudyVector(const MPatientStudy& patientStudy,
					MPatientStudyVector& v)
{

  char* searchCriteria[] = {
    "patid",
    "nam",
    "datbir",
    "sex",
    "stuinsuid",
    // "studat",	// Comment this out; treat for date range
    "stutim",
    "accnum",
    "stuid",
    "modinstu"
  };

  int i;
  MCriteriaVector criteria;

  MString studyDate = patientStudy.studyDate();
  if (studyDate != "") {
    if (studyDate.containsCharacter('-')) {
      MString lower = studyDate.getToken('-', 0);
      MString upper = studyDate.getToken('-', 1);
      if (lower != "") {
	MCriteria p;
	p.attribute = "studat";
	p.oper = TBL_GREATER_EQUAL;
	p.value = lower;
	criteria.push_back(p);
      }
      if (upper != "") {
	MCriteria p;
	p.attribute = "studat";
	p.oper = TBL_LESS_EQUAL;
	p.value = upper;
	criteria.push_back(p);
      }
    } else {
      MCriteria p;
      p.attribute = "studat";
      p.oper = TBL_EQUAL;
      p.value = studyDate;
      criteria.push_back(p);
    }
  }


  const MDomainMap& m = patientStudy.map();
  for(i = 0; i < (int)DIM_OF(searchCriteria); i++) {
    MDomainMap::const_iterator iDomain = m.find(searchCriteria[i]);
    if (iDomain == m.end())   // added for testing -- does this need to be here?
      continue;
    MString s = (*iDomain).second;

    // MString s = m[searchCriteria[i]];

    if (s != "") {
      if ((*iDomain).first == "modinstu") {
	s = "*" + s + "*";
      }

      TBL_OPERATOR oper = TBL_EQUAL;
      if (s.find("*") != string::npos) {
	s.substitute('*', '%');
	oper = TBL_LIKE;
      }
      MCriteria c;
      c.attribute = searchCriteria[i];
      c.oper = oper;
      c.value = s;
      criteria.push_back(c);
    }
  }
  MPatientStudy p;
  mDBInterface->select(p, criteria, patientStudyCallback, &v);
#if 0
  MPatientVector::iterator patientIterator = mPatientVector.begin();
  for (; patientIterator != mPatientVector.end(); patientIterator++)
    v.push_back(*patientIterator);
#endif

  return 0;
}
Esempio n. 7
0
int
MDBImageManager::fillStudyVector(const MStudy& study, MStudyVector& v)
{
  char* searchCriteria[] = {
    "stuinsuid",
    // "studat",		// Comment out as we treat this for date range
    "stutim",
    "accnum",
    "stuid"
  };

  MCriteriaVector criteria;

  MString studyDate = study.studyDate();
  if (studyDate != "") {
    if (studyDate.containsCharacter('-')) {
      MString lower = studyDate.getToken('-', 0);
      MString upper = studyDate.getToken('-', 1);
      if (lower != "") {
	MCriteria p;
	p.attribute = "studat";
	p.oper = TBL_GREATER_EQUAL;
	p.value = lower;
	criteria.push_back(p);
      }
      if (upper != "") {
	MCriteria p;
	p.attribute = "studat";
	p.oper = TBL_LESS_EQUAL;
	p.value = upper;
	criteria.push_back(p);
      }
    } else {
      MCriteria p;
      p.attribute = "studat";
      p.oper = TBL_EQUAL;
      p.value = studyDate;
      criteria.push_back(p);
    }
  }


  int i;

  const MDomainMap& m = study.map();
  for(i = 0; i < (int)DIM_OF(searchCriteria); i++) {
    MDomainMap::const_iterator iDomain = m.find(searchCriteria[i]);
    if (iDomain == m.end())
      continue;

    MString s = (*iDomain).second;

    if (s != "") {
      TBL_OPERATOR oper = TBL_EQUAL;
      if (s.find("*") != string::npos) {
	s.substitute('*', '%');
	oper = TBL_LIKE;
      }
      MCriteria c;
      c.attribute = searchCriteria[i];
      c.oper = oper;
      c.value = s;
      criteria.push_back(c);
    }
  }
  MStudy s;
  mDBInterface->select(s, criteria, studyCallback, this);
  MStudyVector::iterator studyIterator = mStudyVector.begin();
  for (; studyIterator != mStudyVector.end(); studyIterator++)
    v.push_back(*studyIterator);

  return 0;
}
Esempio n. 8
0
int
MHL7DomainXlate::translatePDQQPD3(const MString& s, MPatient& patient) const
{
  MLogClient logClient;
  logClient.log(MLogClient::MLOG_VERBOSE,
	"","MHL7DomainXlate::translatepdQQPD3",
	__LINE__, "Enter method");
  MString queryString = s;
  int idx = 0;
  MString firstName = "";
  MString lastName = "";
  MString patientID = "";
  MString dateOfBirth = "";

  while (queryString.tokenExists('~', idx)) {
    MString x = queryString.getToken('~', idx);
//    cout << idx << ":" << x << endl;
    logClient.logTimeStamp(MLogClient::MLOG_VERBOSE,
	MString("Next token from query: ") + x);
    MString headerCharacter = x.subString(0, 1);
    if (headerCharacter != "@") {
      continue;
    }
    MString x1 = x.subString(1, 0);
    if (!x1.tokenExists('^', 1)) {
      continue;
    }
    MString fieldName = x1.getToken('^', 0);
    MString fieldValue= x1.getToken('^', 1);
    MString debugString = MString("Field Name: ") + fieldName
	+ " Field Value: " + fieldValue;

    logClient.logTimeStamp(MLogClient::MLOG_VERBOSE, debugString);
//    cout << "Field Name:  " << fieldName << endl;
//    cout << "Field Value: " << fieldValue << endl;
    idx++;
    if (fieldName == "PID.5.1.1") {
      lastName = fieldValue;
    } else if (fieldName == "PID.5.2") {
      firstName = fieldValue;
    } else if (fieldName == "PID.3.1") {
      patientID = fieldValue;
    } else if (fieldName == "PID.7.1") {
      dateOfBirth = fieldValue;
    }
  }
  if (lastName == "" && firstName == "") {
  } else if (firstName == "") {
    patient.patientName(lastName + MString("%"));
  } else if (lastName == "") {
    patient.patientName(MString("%^") + firstName);
  } else {
    patient.patientName(lastName + MString("%^") + firstName + MString("%"));
  }
  patient.patientID(patientID);
  patient.dateOfBirth(dateOfBirth);
  logClient.log(MLogClient::MLOG_VERBOSE,
	"","MHL7DomainXlate::translatepdQQPD3",
	__LINE__, "Exit method");
  return 0;
}