def getDeAttachQuery(self, date): u""" Получить список записей на открепление от МО """ try: port = self.getPort() req = srv.GetQueryForDeAttachForMO() req._username = self.username req._password = self.password req._sendercode = self.senderCode req._synhdate = toDateTimeTuple(date) resp = port.GetQueryForDeAttachForMO(req) responceErrors = self.getResponsePackageErrors(resp._orderpack) if responceErrors: raise CSynchronizeAttachException(u','.join( map(unicode, responceErrors))) return map(self.getDeAttachQueryInfo, resp._orderpack._p11_list._p_10orcl) except SocketError as e: raise CSynchronizeAttachException( CR23AttachService.getNoConnectMessage(e.errno)) except Exception: raise finally: if self.tracefile: self.tracefile.flush()
def getAttachInformation(self, clientInfo): u""" Проверка факта прикрепления пациента """ try: port = self.getPort() req = srv.GetAttachInformation() req._username = self.username req._password = self.password req._sendercode = self.senderCode self.insertPackageInformation( req, self.senderCode, srv.ns0.cAttachInformationPackage_Def) req._orderpack._p11_pr = self.getPersonDef(clientInfo, '_p11_pr') resp = port.GetAttachInformation(req) responcepack = resp._responcepack responceInfo = responcepack._p10_packrespinf responceErrors = self.getResponsePackageErrors(responceInfo) if responceErrors: raise CSynchronizeAttachException(u','.join( map(unicode, responceErrors))) attachList = responcepack._p11_atachlist._l10_orcl if not attachList: errorList = [ AttachError(e._e10_ecd, forceUnicode(e._e11_ems)) for e in responceInfo._r12_orerl._f10_orflker[0]. _f11_flkerrorList._f10_flkerror ] if AttachError.AttachesNotFound in [e.code for e in errorList]: return AttachResult(result=AttachedClientInfo()) else: return AttachResult(errors=errorList) node = attachList[0] # len > 1 ? client = self.getClientInfo(node._p12_pr) client.attaches = self.getAttachInfoList(node) return AttachResult(result=client) except SocketError as e: raise CSynchronizeAttachException( CR23AttachService.getNoConnectMessage(e)) except Exception: raise finally: if self.tracefile: self.tracefile.flush()
def sendAttachDoctorSectionInfo(self, personAttachInfoList): u""" Передать сведения об участках в МО и медицинском персонале """ try: port = self.getPort() req = srv.SendAttachDoctorSectionInformation() req._username = self.username req._password = self.password req._sendercode = self.senderCode self.insertPackageInformation(req, self.senderCode, srv.ns0.cAttachDoctorSection_Def) req._orderpack._p11_mocd = personAttachInfoList[ 0].orgCode or self.senderCode req._orderpack._p12_orcl = map(self.getAttachDoctorSectionDef, personAttachInfoList) resp = port.SendAttachDoctorSectionInformation(req) return self.getBadResults(resp._responcepack, [p.id for p in personAttachInfoList]) except SocketError as e: raise CSynchronizeAttachException( CR23AttachService.getNoConnectMessage(e.errno)) except Exception: raise finally: if self.tracefile: self.tracefile.flush()
def makeDeAttach(self, clientAttachInfoList): u""" Выполнить действие по откреплению пациентов """ try: port = self.getPort() orgCode = clientAttachInfoList[0].attach.orgCode or self.senderCode req = srv.MakeDeAttachAction() req._username = orgCode req._password = self.password req._sendercode = orgCode self.insertPackageInformation(req, orgCode, srv.ns0.cDeAttachPersonPackage_Def) req._orderpack._p11_deatachlist = self.getDeAttachListDef( clientAttachInfoList) resp = port.MakeDeAttachAction(req) return self.getBadResults( resp._orderpack, [c.attach.id for c in clientAttachInfoList]) except SocketError as e: raise CSynchronizeAttachException( CR23AttachService.getNoConnectMessage(e.errno)) except Exception: raise finally: if self.tracefile: self.tracefile.flush()
def getAttachListByRangeAct(self, year, month, startId): try: port = self.getPort() req = srv.GetAttachListByRangeAct() req._username = self.username req._password = self.password req._sendercode = self.senderCode req._startid = startId req._monthact = month req._yearact = year resp = port.GetAttachListByRangeAct(req) orderpack = resp._orderpack nextStartId = resp._orderpack._p11_nid attachClientInfoList = orderpack._p12_alist._l10_orcl return nextStartId, attachClientInfoList except SocketError as e: raise CSynchronizeAttachException( CR23AttachService.getNoConnectMessage(e.errno)) except Exception: QtGui.qApp.logCurrentException() raise finally: if self.tracefile: self.tracefile.flush()
def getAttachListByRange(self, startId): try: port = self.getPort() req = srv.GetAttachListByRange() req._username = self.username req._password = self.password req._sendercode = self.senderCode req._startid = startId req._isadres = True self.insertPackageInformation(req, self.senderCode, srv.ns0.GetAttachListByRange_Def) resp = port.GetAttachListByRange(req) responseErrors = self.getResponsePackageErrors(resp._orderpack) if responseErrors: raise CSynchronizeAttachException(u','.join( map(unicode, responseErrors))) nextId = resp._orderpack._p11_nid attachedList = resp._orderpack._p12_alist._l10_orcl if self.tracefile: self.tracefile.write( 'GetAttachListByRange(startId=%s): %s items' % (startId, len(attachedList))) self.tracefile.flush() return nextId, attachedList except CSynchronizeAttachException: QtGui.qApp.logCurrentException() raise except SocketError as e: QtGui.qApp.logCurrentException() raise CSynchronizeAttachException( CR23AttachService.getNoConnectMessage(e.errno)) except Exception: QtGui.qApp.logCurrentException() raise finally: if self.tracefile: self.tracefile.flush()
def getDeattachByDate(self, date): u""" Получить список открепившихся граждан с определенной даты {date} по текущую """ try: port = self.getPort() req = srv.GetDeAttachByDate() req._username = self.username req._password = self.password req._sendercode = self.senderCode req._controldate = toDateTimeTuple(date) resp = port.GetDeAttachByDate(req) responceErrors = self.getResponsePackageErrors(resp) if responceErrors: raise CSynchronizeAttachException(u','.join( map(unicode, responceErrors))) deattachList = resp._orderpack._p11_deatachlist._l10_orcl if self.tracefile: self.tracefile.write('GetDeAttachByDate(): %s items' % len(deattachList)) self.tracefile.flush() return map(self.getDeAttachedClientInfo, deattachList) except SocketError as e: QtGui.qApp.logCurrentException() raise CSynchronizeAttachException( CR23AttachService.getNoConnectMessage(e.errno)) except Exception: QtGui.qApp.logCurrentException() raise finally: if self.tracefile: self.tracefile.flush()
def makeTestConnect(self): u""" Проверка связи с сервером МИАЦ """ try: port = self.getPort() req = srv.MakeTestConnect() resp = port.MakeTestConnect(req) return CR23LoginAccessService.TestConnectResultMap[resp._retresult] except SocketError as e: raise CSynchronizeAttachException( CR23AttachService.getNoConnectMessage(e.errno)) except Exception: raise except CSynchronizeAttachException: raise finally: if self.tracefile: self.tracefile.flush()
def setLoginAccess(self, username, password, senderCode, oldpassword=None): u""" Регистрация организации в сервисе """ port = self.getPort() try: req = srv.SetLoginAccess() req._username = username req._password = password req._sendercode = senderCode req._oldpassword = oldpassword resp = port.SetLoginAccess(req) return CR23LoginAccessService.LoginErrorMap[resp._return] except SocketError as e: raise CSynchronizeAttachException( CR23AttachService.getNoConnectMessage(e.errno)) except Exception: return CR23LoginAccessService.LoginErrorMap[0] finally: if self.tracefile: self.tracefile.flush()
def getAttachMOStreetSection(self): u""" Извлечь информацию о домах или домовладениях относящихся к врачебному участку в рамках медицинской организации """ port = self.getPort() try: req = srv.GetAttachMoStreetSection() req._username = self.username req._password = self.password req._sendercode = self.senderCode resp = port.GetAttachMoStreetSection(req) return None except SocketError as e: raise CSynchronizeAttachException( CR23AttachService.getNoConnectMessage(e.errno)) except Exception as e: QtGui.qApp.logCurrentException() finally: if self.tracefile: self.tracefile.flush()
def sendAttachMOStreetSection(self, recordList): u""" Передать информацию о домах или домовладениях относящихся к врачебному участку в рамках медицинской организации """ port = self.getPort() try: req = srv.SendAttachMoStreetSection() req._username = self.username req._password = self.password req._sendercode = self.senderCode self.insertPackageInformation(req, self.senderCode, srv.ns0.cAttachMoStreetSection_Def) resp = port.SendAttachMoStreetSection(req) except SocketError as e: raise CSynchronizeAttachException( CR23AttachService.getNoConnectMessage(e.errno)) except Exception as e: QtGui.qApp.logCurrentException() finally: if self.tracefile: self.tracefile.flush()
def sendDeAttachQuery(self, deattachQueryList): u""" Передать информацию в ТФОМС КК о запросах на открепление от МО """ try: port = self.getPort() req = srv.SendQueryForDeAttachForMO() req._username = self.username req._password = self.password req._sendercode = self.senderCode self.insertPackageInformation( req, self.senderCode, srv.ns0.cDeAttachQueryForMOPackage_Def) req._orderpack._p11_list = srv.ns0.cDeAttachQueryForMOList_Def( '_p11_list') req._orderpack._p11_list._p_10orcl = map( self.getDeAttachQueryRecordDef, deattachQueryList) resp = port.SendQueryForDeAttachForMO(req) responceErrors = self.getResponsePackageErrors( resp._orderpack._p10_packrespinf) return [ AttachResult(attachId=deattachQuery.id, errors=responceErrors) for deattachQuery in deattachQueryList ] except SocketError as e: raise CSynchronizeAttachException( CR23AttachService.getNoConnectMessage(e.errno)) except Exception: raise finally: if self.tracefile: self.tracefile.flush()