How to use readResult method in wpt

Best JavaScript code snippet using wpt

read-card.js

Source:read-card.js Github

copy

Full Screen

1angular.module('hr.templateCache').run(['$templateCache', function ($templateCache) {2 $templateCache.put('read-card-template.html', ' <div class="control-group papers-num" >\n <label class="control-label" ng-bind="displayLabel"></label>\n\n <div class="controls">\n <input class="input-medium" style="width: 85px;" type="text" tablename="DEFINED_IDENTIFICATION_CLASS" id="cardType" ng-focus="changeKeyBoardArea()"\n table-dict-tips="cardTypeOptions" ng-model="visitRecord.cardType" ng-disabled="isReadOnly">\n\n <div class="input-append" style="margin-left:-4.5px;">\n <input id="cardNo" class="input-large" type="text" style="width: 210px;border-left: 0;" ng-disabled="isReadOnly"\n ng-model="visitRecord.cardNo" ng-focus="changeKeyBoardArea()" ng-show="noenter!==\'true\'"\n ui-keypress="{13:\'keypressQueryPatientbyCardId()\'}" click-outside="clickOutSide()" maxlength="40"/>\n <button class="btn fg-emphasize-color" style="width:69px;" ng-click="clickRead()" type="button">读卡</button>\n </div>\n </div>\n </div>\n\n <div hr-draggable modal="modalSameCodePatient" options="modalSameCodePatientOpts">\n <div class="modal-header">\n <button type="button" class="close" ng-click="closeSameCodePatient(\'close\')">&times;</button>\n <h5>身份证号重复患者列表</h5>\n </div>\n <div class="modal-body">\n <div id="general-height2" class="gridStyle" ng-grid="sameCodePatientGrid" ></div>\n </div>\n <div class="modal-footer">\n <button class="btn btn-primary" ng-click="selectOnePatient()">确&nbsp;认</button>\n <button class="btn btn-primary" ng-click="closeSameCodePatient(\'close\')">取&nbsp;消</button>\n </div>\n </div>\n\n <style type="text/css">\n .same-patient-modal.modal{width:97%;top:10%;}\n .same-patient-modal.modal .icon-link-color{color:#2d89ef;padding-top: 5px;}\n .same-patient-modal.modal.fade{opacity: 1;}\n </style>\n \n\n \n\n\n ');3}]);4//读卡指令5angular.module('hr.directives').directive("readCard", ["$parse", "$http", "hrDialog", "HrReadCard", "HrCardType",6 function ($parse, $http, hrDialog, HrReadCard, HrCardType) {7 var readCardObject = {8 restrict: "E",9 templateUrl: "read-card-template.html",10 scope: {11 callback: "=",12 option: "=",13 focus: "=",14 config: "@" //noCheck clinic表示来自挂号等需要调主索引的界面; patient表示来自主索引,15 },16 controller: ["$scope", function ($scope) {17 var unitCode = getTopLevelConfig("unit-code") || "60002530009"; //医院体系代码18 var hospitalBaseCode = getTopLevelConfig("hospital-base-code") || "600025"; //基层医疗机构代码19 $scope.displayLabel = ($scope.noenter === "true" ? "卡类型" : "证件及编号" );20 $scope.visitRecord = {21 cardType: "",22 cardNo: "",23 insuranceNo: ""24 };25 $scope.cacheCardInfo = angular.copy($scope.visitRecord);26 $scope.$watch('visitRecord', function (newValue, oldValue) {27 if (isNull(newValue.cardNo)) {28 $scope.cacheCardInfo.cardNo = "";29 }30 if (isNull(newValue.cardType)) {31 $scope.cacheCardInfo.cardType = "";32 }33 }, true);34 $scope.changeKeyBoardArea = function () {35 $scope.focus.setFocusPatientInfo(true);36 };37 $scope.clickOutSide = function(){38 $scope.focus.toChangeMouse(true);39 };40 //根据患者id查询出的患者信息(将证件类型和证件号)41 $scope.option.setPatientInfo = function (patientInfo) {42 console.log("主界面传给指令的数据---------");43 console.log(patientInfo);44 if (isNull(patientInfo)) {45 $scope.visitRecord = {46 cardType: "",47 cardNo: "",48 insuranceNo: ""49 };50 $scope.cacheCardInfo = angular.copy($scope.visitRecord);51 return false;52 }53 if ($scope.config === "return" || $scope.config === "appoint") {54 $scope.isReadOnly = patientInfo;55 return false;56 }57 if (!isNull(patientInfo.idno)) {58 $scope.visitRecord = {59 cardType: HrCardType.ID_CARD,60 cardNo: patientInfo.idno,61 insuranceNo: ""62 };63 return false;64 }65 };66 //卡类型指令输入框参数67 $scope.cardTypeOptions = {68 selectedItem: function (data, status) {69 $scope.visitRecord.cardNo = "";70 if (!HrStr.isNull(data)) {71 $scope.visitRecord.cardType = data.codeName;72 }73 if (status !== "outside") {74 setTimeout(function () {75 $("#cardType").blur();76 $("#cardNo").focus();77 }, 0);78 }79 }80 };81 //-----------------------------------------读卡入口---------------------------------------------------------82 //快捷键读卡83 $scope.option.readCard = function (cardInfo) {84 $scope.visitRecord.cardType = cardInfo.cardType;85 $scope.clickRead();86 };87 //根据卡类型和卡号查询88 $scope.keypressQueryPatientbyCardId = function () {89 if ($scope.visitRecord.cardType === HrCardType.BEIJING_INSURANCE) {90 return false;91 }92 $scope.visitRecord.insuranceNo = ($scope.visitRecord.cardType === HrCardType.MILITARY_MEDICAL ? $scope.visitRecord.cardNo : "");93 var readResult = angular.copy($scope.visitRecord);94 readResult.isFromRead = false;95 if ((isNull(readResult.cardNo) && isNull(readResult.insuranceNo)) ||96 ($scope.cacheCardInfo.cardType === readResult.cardType &&97 ((!isNull(readResult.cardNo) && $scope.cacheCardInfo.cardNo === readResult.cardNo) ||98 (!isNull(readResult.insuranceNo) && $scope.cacheCardInfo.insuranceNo === readResult.insuranceNo)))) {99 return false;100 }101 if (isNull($scope.visitRecord.cardType)) {102 return false;103 }104 $scope.cacheCardInfo = angular.copy(readResult);105 $http.get(Path.getUri("api/identification-class/by-identification-name/") + $scope.visitRecord.cardType).success(function (identification) {106 readResult.classType = identification.classType;107 if (identification.classType === "3") {108 isReturnReadObject(readResult);109 } else if (identification.classType === "4") {110 isReturnReadObject(readResult);111 } else {112 $http.get(Path.getUri("api/pat-identification-rec/get-patientId-by-identification/") + identification.identificationClassCode + "/" + $scope.visitRecord.cardNo).success(function (patientId) {113 if (patientId) {114 queryPatMasterByPatientId(patientId, function (patMaster) {115 returnedCardResult(patMaster.patientid, patMaster, true, readResult.isFromRead);116 });117 } else {118 hrDialog.dialog(hrDialog.typeEnum.WARN, {message: "不存在该卡类型的患者ID!"});119 }120 }).error(function (data, status) {121 hrDialog.dialog(hrDialog.typeEnum.EXCEPTION, {message: "查询患者识别号对照表出错!"});122 });123 }124 });125 };126 //根据设备类型读外设127 $scope.clickRead = function () {128 if (!$scope.visitRecord.cardType) {129 return false;130 }131 HrReadCard.readCard($scope.visitRecord.cardType, function (readCardResult) {132// var readCardResult = {};133// switch ($scope.visitRecord.cardType) {134// case HrCardType.ID_CARD :135// readCardResult = {136// name: "宋某波",137// sex: "女",138// nation: "壮族",139// birthday: "2011-11-11",140// address: "河北省沧州市沧县旧州镇",141// cardType: "身份证",142// idCardNo: "110103392009073015",143// insuranceNo: "",144// insuranceType: "",145// newAddress: "河北省石家庄市元氏县赵同乡",146//// photoLocation : "C:\\Users\\miao\\AppData\\Local\\Temp\\heren\\idcard\\zp.bmp",147// state: {success: true}148// };149// break;150// case HrCardType.BEIJING_INSURANCE :151// readCardResult = {152// name: "测试卡11",153// sex: "男",154// nation: "",155// birthday: "1972-11-11",156// address: "",157// cardType: "北京医保",158// idCardNo: "132130198911112222",159// insuranceNo: "107765716011",160// insuranceType: "",161// chargeType: "北京医保",162// state: {success: true}163// };164// break;165// case HrCardType.MILITARY_MEDICAL:166// readCardResult = {167// accountBalance: "0",168// accountRatedAmount: "0",169// accountType: "",170// assignCenter: "1070000000",171// assignDate: "20110423",172// birthPlace: "350623",173// birthday: "1981-10-01",174// cardNo: "815107110412120206",175// cardStatus: "0",176// cardType: "军队医改",177// chargeType: "军队医改",178// designatedHospital: "600200",179// designatedPoliclinic: "60020040106",180// expirationDate: "350623198912015736",181// fundType: "", gradeOfDuty: "",182// gradeOfTechnic: "", gradeOfTitle: "",183// identity: "士兵", initialAmount: "0",184// insuranceNo: "2222222", insuranceType: "免费医疗",185// isFromRead: true, maritalStatus: "", name: "李十", nation: "苗族",186// patientId: "", rankCode: "", relatedInsuranceNo1: "",187// relationship1: "", settleDate: "", sex: "女", state: {success: true}, subsidyType: "", unit: "60020000178", workingStatus: "0"188// };189// break;190// }191 console.log("读卡得到的数据-----------------");192 console.log(readCardResult);193 if (readCardResult.state.success) {194 $http.get(Path.getUri("api/identification-class/by-identification-name/") + $scope.visitRecord.cardType).success(function (identification) {195 readCardResult.isFromRead = true;196 readCardResult.classType = identification.classType;197 readCardResult.cardType = $scope.visitRecord.cardType;198 isReturnReadObject(readCardResult);199 });200 } else {201 hrDialog.dialog(hrDialog.typeEnum.EXCEPTION, { message: readCardResult.state.errorMessage, detail: readCardResult.state.errorMessage });202 }203 });204 };205 var getAddressCode = function (address, callback) {206 $http.get(Path.getUri("api/common-resource/id-card-inf/") + address).success(function (data) {207 callback(data.districtNo);208 }).error(function () {209 callback("");210 });211 };212 /**213 *214 * @param checkStatus true直接返回,false不返回215 * @param readResult 读出的卡信息216 */217 $scope.readResult = null;218 var isReturnReadObject = function (readResult) {219 switch (readResult.cardType) {220 case HrCardType.ID_CARD :221 readResult.cardNo = readResult.idCardNo || readResult.cardNo;222 $scope.visitRecord.cardNo = readResult.cardNo;223 if (readResult.isFromRead) {224 getAddressCode(readResult.address, function (addressCode) {225 readResult.birthPlace = addressCode;226 readResult.nativePlace = addressCode;227 readResult.registeredResidenceCode = addressCode;228 getAddressCode(readResult.newAddress, function (addressCode) {229 readResult.presentAddressCode = addressCode;230 $scope.readResult = angular.copy(readResult);231 queryPatMasterByIdNo(readResult, readResult.cardNo);232 });233 });234 } else {235 $scope.readResult = angular.copy(readResult);236 queryPatMasterByIdNo(readResult, readResult.cardNo);237 }238 break;239 case HrCardType.BEIJING_INSURANCE :240 $scope.visitRecord.cardNo = readResult.insuranceNo;241 $scope.readResult = angular.copy(readResult);242 queryPatMasterBySecurityNo(readResult, readResult.insuranceNo);243 break;244 case HrCardType.MILITARY_MEDICAL:245 $scope.visitRecord.cardNo = readResult.insuranceNo;246 $scope.readResult = angular.copy(readResult);247 queryPatientByInsuranceNo(readResult, readResult.insuranceNo);248 break;249 default :250 queryPatMasterByOtherCard(readResult, readResult.cardNo);251 $scope.readResult = angular.copy(readResult);252 }253 };254 //根据患者身份证号查询主索引255 var queryPatMasterByIdNo = function (readResult, idNo) {256 if (checkIsExistCardNo(readResult.cardType, idNo)) {257 var url = Path.getUri("api/patient") + "/byidno/" + idNo;258 queryPatMasterByCondition(url, readResult);259 }260 };261 //根据医保账号和医保类型查询主索引262 var queryPatMasterBySecurityNo = function (readResult, securityNo) {263 if (checkIsExistCardNo(readResult.cardType, securityNo)) {264 var url = Path.getUri("api/patient") + "/by-securityno/" + readResult.cardType + "/" + securityNo;265 queryPatMasterByCondition(url, readResult);266 }267 };268 //根据患者Id查询主索引信息269 var queryPatientByInsuranceNo = function (readResult, insuranceNo) {270 //根据患者类型查询军保账户,根据patientId查询患者类型271 if (checkIsExistCardNo(readResult.cardType, insuranceNo)) {272 var insuranceAccount = {273 insuranceNo: insuranceNo,274 patientId: readResult.patientId,275 name: readResult.name,276 sex: readResult.sex,277 dateOfBirth: readResult.birthday,278 unit: readResult.unit,279 identityClass: readResult.identity,280 insuranceType: readResult.insuranceType,281 accountRatedAmount: readResult.accountRatedAmount,282 accountInitialAmount: readResult.initialAmount,283 accountBalance: readResult.accountBalance,284 relatedInsuranceNo1: readResult.relatedInsuranceNo1,285 relationship1: readResult.relationship1,286 accountStatus: '0',287 operator: getStaffDict().staffName,288 birthPlace: readResult.birthPlace,289 nation: readResult.nation,290 maritalStatus: readResult.maritalStatus,291 designatedPoliclinic: readResult.designatedPoliclinic,292 designatedHospital: readResult.designatedHospital,293 workingStatus: readResult.workingStatus,294 fundType: readResult.fundType,295 subsidyType: readResult.subsidyType296 };297 $http.post(Path.getUri("api/army-insurance/legal-account/") + unitCode + "/" + hospitalBaseCode, insuranceAccount).success(function (accountInfo) {298 console.log("军人保障卡账户信息--------------------------");299 console.log(accountInfo);300 if (accountInfo) {301 //todo 合法性校验302 readResult.birthPlace = accountInfo.birthPlace;303 readResult.birthday = accountInfo.birthday;304 readResult.designatedPoliclinic = accountInfo.designatedPoliclinic;305 readResult.idNo = accountInfo.idNo;306 readResult.idCardNo = accountInfo.idNo;307 readResult.identity = accountInfo.identity;308 readResult.name = accountInfo.name;309 readResult.namePhonetic = accountInfo.namePhonetic;310 readResult.nation = accountInfo.nation;311 readResult.patientId = accountInfo.patientId;312 readResult.sex = accountInfo.sex;313 readResult.unit = accountInfo.unit;314 readResult.workingStatus = accountInfo.workingStatus;315 queryPatMasterByPatientIdInsurance(accountInfo.patientId, function (patMaster) {316 if (patMaster) {317 checkCardInfoAndPatMaster(readResult, patMaster, function (patMasterInfo) {318 returnedCardResult(patMasterInfo.patientid, patMasterInfo, true, readResult.isFromRead);319 });320 } else {321 readResult.patientId = "";322 returnedCardResult(readResult.patientId, readResult, false, readResult.isFromRead);323 }324 });325 } else {326 hrDialog.dialog(hrDialog.typeEnum.WARN, {message: '不存在【' + readResult.insuranceNo + '】的军队医改账户信息!'}).close(function () {327 $scope.callback.getPatientInfoFromCard();328 });329 }330 }331 ).error(function (data, status) {332 HrUtils.httpError(data, status, hrDialog);333 });334 }335 };336 var queryPatMasterByPatientIdInsurance = function (patientId, callback) {337 if (patientId) {338 $http.get(Path.getUri("api/patient") + "/byid/" + patientId).success(function (patient) {339 callback(patient);340 }).error(function () {341 callback();342 });343 } else {344 callback();345 }346 };347 //查询主索引返回信息348 var queryPatMasterByPatientId = function (patientId, callback) {349 if (patientId) {350 $http.get(Path.getUri("api/patient") + "/byid/" + patientId).success(function (patient) {351 callback(patient);352 }).error(function () {353 hrDialog.dialog(hrDialog.typeEnum.EXCEPTION, {message: '查询主索引出错!'});354 });355 } else {356 callback();357 }358 };359 //根据其他卡类型和卡号查询主索引360 var queryPatMasterByOtherCard = function (readResult, cardNo) {361 if (checkIsExistCardNo(readResult.cardType, cardNo)) {362 var url = Path.getUri("api/pat-identification-rec/get-rec-patientId/") + cardNo;363 queryPatMasterByCondition(url, readResult);364 }365 };366 //校验是否存在卡号367 var checkIsExistCardNo = function (cardType, cardNo) {368 if (cardNo) {369 return true;370 } else {371 hrDialog.dialog(hrDialog.typeEnum.WARN, {message: '请填写【' + cardType + '】编号!'});372 }373 };374 //查询主索引375 var queryPatMasterByCondition = function (url, readResult) {376 $http.get(url).success(function (patMasterList) {377 isExistPatMaster(readResult, patMasterList);378 }).error(function () {379 hrDialog.dialog(hrDialog.typeEnum.WARN, {message: '根据【' + readResult.cardType + '】的查询主索引出错!'});380 });381 };382 /**383 *返回主索引信息384 * @param readResult 读到的卡信息385 * @param patMasterList 查询到的患者主索引信息386 */387 var isExistPatMaster = function (readResult, patMasterList) {388 if (patMasterList.length > 1) {389 $scope.sameCodePatients = [];390 $scope.sameCodePatients = patMasterList;391 $scope._originalKeyMap = angular.copy(Mousetrap.getKeyMap());392 Mousetrap.reset();393 bindKey();394 $scope.modalSameCodePatient = true;395 } else if (patMasterList.length === 1) {396 if (readResult.isFromRead) {397 checkCardInfoAndPatMaster(readResult, patMasterList[0], function (patMasterInfo) {398 if ($scope.config !== "patient" && (patMasterInfo.mergedindicator === 0 || patMasterInfo.mergedindicator === "0")) {399 checkIsMerged(patientId, function (remainId) {400 hrDialog.dialog(hrDialog.typeEnum.WARN, {title: '提示', message: '该证件号的患者已经被合并,请使用保留的ID[' + remainId + ']号!'}).close(401 function () {402 queryPatMasterByPatientId(remainId, function (patMaster) {403 returnedCardResult(patMaster.patientid, patMaster, true, readResult.isFromRead);404 });405 }406 );407 });408 } else {409 returnedCardResult(patMasterInfo.patientid, patMasterInfo, true, readResult.isFromRead);410 }411 });412 } else {413 var patientId = patMasterList[0].patientId || patMasterList[0].patientid;414 var merged = patMasterList[0].mergedindicator || patMasterList[0].mergedIndicator;415 if ((merged === 0 || merged === "0") && $scope.config !== "patient") {416 checkIsMerged(patientId, function (remainId) {417 hrDialog.dialog(hrDialog.typeEnum.WARN, {title: '提示', message: '该证件号的患者已经被合并,请使用保留的ID[' + remainId + ']号!'}).close(418 function () {419 queryPatMasterByPatientId(remainId, function (patMaster) {420 returnedCardResult(patMaster.patientid, patMaster, true, readResult.isFromRead);421 });422 }423 );424 });425 } else {426 queryPatMasterByPatientId(patientId, function (patMaster) {427 returnedCardResult(patMaster.patientid, patMaster, true, readResult.isFromRead);428 });429 }430 }431 } else {432 if (readResult.isFromRead) {433 returnedCardResult(readResult.patientid, readResult, false, readResult.isFromRead);434 } else {435 if ($scope.config === "appoint") {436 if (readResult.classType === "3") {437 returnedCardResult("", {idCardNo: readResult.cardNo}, false, false);438 } else if (readResult.classType === "4") {439 returnedCardResult("", {insuranceNo: readResult.cardNo, insuranceType: readResult.cardType}, false, false);440 }441 } else {442 hrDialog.dialog(hrDialog.typeEnum.WARN, {message: "不存在该编号的患者信息!"}).close(function () {443 $scope.callback.getPatientInfoFromCard();444 });445 }446 }447 }448 };449 var checkIsMerged = function (patientId, callback) {450 $http.get(Path.getUri("api/patient/notMerged/") + patientId).success(function (remainId) {451 if (remainId) {452 callback(remainId);453 } else {454 hrDialog.dialog(hrDialog.typeEnum.WARN, {message: "不存在保留的患者ID!"});455 }456 });457 };458 var updateOtherInfo = function (checkCondition, photoFile, callback) {459 var requestUri = Path.getUri("api/patient/update-pat-master/" + getStaffDict().staffName + "/" + getStaffDict().empId);460 var updateObject = {461 name: checkCondition.name,462 sex: checkCondition.sex,463 nation: checkCondition.nation,464 dateOfBirth: checkCondition.birthday,465 identity: checkCondition.identity,466 birthPlace: checkCondition.birthPlace,467 chargeType: checkCondition.chargeType,468 nativePlace: checkCondition.nativePlace,469 idNo: checkCondition.idNo,470 securityType: checkCondition.insuranceType,471 securityNo: checkCondition.insuranceNo,472 registeredResidenceCode: checkCondition.registeredResidenceCode,473 presentAddressCode: checkCondition.presentAddressCode,474 patientId: checkCondition.patientId,475 photoFile: photoFile476 };477 $http.put(requestUri, updateObject).success(function (data, status) {478 callback(data);479 }).error(function () {480 callback();481 });482 };483 //将卡信息更新到主索引484 var updatePatMaster = function (checkCondition, callback) {485 if (checkCondition.photoLocation) {486 $http.get(Path.getWebstartUri("api/file?path=" + checkCondition.photoLocation)).success(function (photoFile) {487 updateOtherInfo(checkCondition, photoFile, function (data) {488 callback(data);489 });490 }).error(function (data, status) {491 console.log(status);492 console.log(data);493 });494 } else {495 updateOtherInfo(checkCondition, "", function (data) {496 callback(data);497 });498 }499 };500 //校验卡内信息和主索引信息是否一致501 var checkCardInfoAndPatMaster = function (readResult, pat, callback) {502 var patientId = pat.patientId || pat.patientid;503 if (readResult.name === pat.name) {504 updatePatMaster({505 name: readResult.name,506 sex: readResult.sex,507 birthday: readResult.birthday,508 nation: readResult.nation,509 identity: readResult.identity,510 birthPlace: readResult.birthPlace,511 chargeType: readResult.chargeType,512 nativePlace: readResult.nativePlace,513 idNo: readResult.idCardNo,514 photoLocation: readResult.photoLocation,515 insuranceType: (readResult.classType === "4" ? readResult.cardType : ""),516 insuranceNo: readResult.insuranceNo,517 registeredResidenceCode: readResult.registeredResidenceCode,518 presentAddressCode: readResult.presentAddressCode,519 patientId: patientId}, function (patMasterInfo) {520 if (patMasterInfo) {521 queryPatMasterByPatientId(patMasterInfo.patientid, function (patMaster) {522 if (patMaster) {523 callback(patMaster);524 } else {525 hrDialog.dialog(hrDialog.typeEnum.EXCEPTION, {message: "查询主索引失败!"});526 }527 });528 } else {529 hrDialog.dialog(hrDialog.typeEnum.EXCEPTION, {message: "同步主索引信息失败!"});530 }531 });532 } else {533 if ($scope.config !== "noCheckName") {534 //提示不一致,误操作535 hrDialog.dialog(hrDialog.typeEnum.WARN, {message: "患者卡内姓名和主索引不一致!"}).close(function () {536 $scope.callback.getPatientInfoFromCard();537 });538 } else {539 returnedCardResult(patientId, readResult, false, readResult.isFromRead);540 }541 }542 };543 //-------------------------------------------输出信息---------------------------------------------------544 /**545 *546 * @param patientId547 * @param readResult548 * @param fromPat true来自主索引 false来自读卡549 */550 var returnedCardResult = function (patientId, readResult, fromPat, isFromRead) {551 var returnedObject = {};552 console.log("------------------------------------------");553 console.log(readResult);554 if (fromPat) {555 returnedObject = {556 patientId: patientId,557 patientName: readResult.name,558 patientSex: readResult.sex,559 patientBirth: readResult.dateofbirth,560 identity: readResult.identity,561 chargeType: readResult.chargetype,562 idNo: readResult.idno,563 birthPlace: readResult.birthPlaceCode, //出生地564 nation: readResult.nation,565 insuranceType: readResult.securitytype, //医保类型566 insuranceNo: readResult.securityno, //医保账号567 nextOfKin: readResult.nextofkin,568 phoneNumber: readResult.phonenumber569 };570 } else {571 returnedObject = {572 patientId: patientId,573 patientName: readResult.name,574 patientSex: readResult.sex,575 patientBirth: readResult.birthday,576 identity: readResult.identity,577 chargeType: readResult.chargeType,578 idNo: readResult.idCardNo,579 birthPlace: readResult.birthPlace,580 nation: readResult.nation,581 insuranceType: readResult.insuranceType, //医保类型582 insuranceNo: readResult.insuranceNo, //医保账号583 nextOfKin: "",584 phoneNumber: ""585 };586 }587 returnedObject.cardType = $scope.visitRecord.cardType;588 returnedObject.isFromRead = isFromRead;589 if (isFromRead && HrCardType.ID_CARD === returnedObject.cardType) {590 returnedObject.photoLocation = $scope.readResult.photoLocation;//照片路径591 returnedObject.nativePlace = $scope.readResult.nativePlace;592 returnedObject.registeredResidenceCode = $scope.readResult.registeredResidenceCode;593 returnedObject.presentAddressCode = $scope.readResult.presentAddressCode;594 }595 getIdentityAndChargeTypeByCardType(returnedObject.cardType, function (identificationClassDict) {596 if ($scope.readResult) {597 returnedObject.unit = $scope.readResult.unit;598 returnedObject.gradeOfDuty = $scope.readResult.gradeOfDuty;599 returnedObject.designatedPoliclinic = $scope.readResult.designatedPoliclinic;600 returnedObject.workingStatus = $scope.readResult.workingStatus;601 }602 returnedObject.chargeType = (isNull(identificationClassDict.defaultChargeType) ? returnedObject.chargeType : identificationClassDict.defaultChargeType);603 returnedObject.identity = (isNull(identificationClassDict.defaultIdentity) || readResult.cardType === HrCardType.MILITARY_MEDICAL ? returnedObject.identity : identificationClassDict.defaultIdentity);604 returnedObject.classType = identificationClassDict.classType;605 console.log("从读卡指令返回到主界面的对象----------------------");606 console.log(returnedObject);607 $scope.callback.getPatientInfoFromCard(returnedObject);608 });609 };610 var getIdentityAndChargeTypeByCardType = function (cardType, callback) {611 $http.get(Path.getUri("api/identification-class/by-identification-name/") + cardType).success(function (identificationClassDict) {612 callback(identificationClassDict);613 }).error(function (data, status) {614 HrUtils.httpError(data, status, hrDialog);615 });616 };617 //--------------------------处理证件号相同患者信息start----------------------------------618 $scope.selectedPats = [];619 $scope.modalSameCodePatient = false;620 $scope.modalSameCodePatientOpts = {621 dialogClass: "modal same-patient-modal",622 backdropFade: true,623 dialogFade: true,624 keyboard: false,625 backdrop: true,626 backdropClick: false627 };628 $scope.sameCodePatientGrid = {629 data: 'sameCodePatients',630 selectedItems: $scope.selectedPats,631 i18n: 'zh-cn',632 enableRowSelection: true,633 multiSelect: false,634 enableColumnResize: true,635 beforeSelectionChange: function (rowItem, event) {636 if (event.type === "keydown" && event.keyCode === 13) {637 return false;638 }639 return true;640 },641 columnDefs: [642 {field: 'patientId', displayName: '患者ID', width: "11%"},643 {field: 'name', displayName: '姓名', width: "11%"},644 {field: 'sex', displayName: '性别', width: "5%"},645 {field: 'age ', displayName: '年龄', width: "5%"},646 {field: 'birthPlace ', displayName: '出生地', width: "20%"},647 {field: 'nowAddress ', displayName: '现住址', width: "20%"},648 {field: 'phoneNum ', displayName: '联系电话', width: "12%"} ,649 {field: 'nextOfkIn ', displayName: '联系人', width: "9%"} ,650 {field: 'relationship ', displayName: '关系', width: "8%"}651 ],652 rowTemplate: "<div ng-style=\"{ \'cursor\': row.cursor }\" ng-repeat=\"col in renderedColumns\" ng-dblclick=\"selectOnePatient()\"\n ng-class=\"col.colIndex()\" class=\"ngCell {{col.cellClass}}\">\n <div class=\"ngVerticalBar\" ng-style=\"{height: rowHeight}\" ng-class=\"{ ngVerticalBarVisible: !$last }\">&nbsp;</div>\n <div ng-cell></div>\n</div> "653 };654 $scope.$on('ngGridEventData', function () {655 $scope.sameCodePatientGrid.selectRow(0, true);656 setTimeout(function () {657 $scope.sameCodePatientGrid.ngGrid.$viewport.focus();658 }, 0);659 $scope.sameCodePatientGrid.ngGrid.$viewport.bind("keydown", function (event) {660 var index = $scope.sameCodePatientGrid.$gridScope.selectionProvider.lastClickedRow.rowIndex;661 var selectedObject = angular.copy($scope.sameCodePatients[index]);662 if (event.keyCode === 13 && selectedObject) {663 if (!$scope.$$phase) {664 $scope.$apply(getAddedAndConvertPatientInfo(selectedObject));665 }666 }667 });668 });669 function getAddedAndConvertPatientInfo(patientInfo) {670 if ($scope.readResult.isFromRead) {671 checkCardInfoAndPatMaster($scope.readResult, patientInfo, "", function (patMasterInfo) {672 queryPatMasterByPatientId(patMasterInfo.patientid, function (patMaster) {673 returnedCardResult(patMaster.patientid, patMaster, true, $scope.readResult.isFromRead);674 });675 });676 } else {677 queryPatMasterByPatientId(patientInfo.patientId, function (patMaster) {678 returnedCardResult(patMaster.patientid, patMaster, true, $scope.readResult.isFromRead);679 });680 }681 $scope.closeSameCodePatient();682 }683 $scope.selectOnePatient = function () {684 getAddedAndConvertPatientInfo($scope.selectedPats[0]);685 };686 $scope.closeSameCodePatient = function (indicator) {687 Mousetrap.reset();688 Mousetrap.setKeyMap($scope._originalKeyMap);689 $scope.modalSameCodePatient = false;690 if (indicator === "close") {691 $scope.callback.getPatientInfoFromCard(null);692 }693 };694 //----------------------------处理相同患者信息end------------------------------------------------------------695 var readCardKey = function () {696 $http.get(Path.getUri("api/identification-class/all-identification")).success(function (identification) {697 angular.forEach(identification, function (object) {698 if (object.hotKey) {699 Mousetrap.bindGlobal(object.hotKey, function (e) {700 e.preventDefault();701 $scope.visitRecord.cardType = object.identificationClassName;702 $scope.clickRead();703 if(!$scope.$$phase){704 $scope.$apply();705 }706 return false;707 });708 }709 });710 });711 };712 readCardKey();713 $scope.option.bindReadCardKey = function () {714 readCardKey();715 };716 var bindKey = function () {717 readCardKey();718 Mousetrap.bindGlobal('esc', function () {719 $scope.closeSameCodePatient("close");720 if (!$scope.$$phase) {721 $scope.$apply();722 }723 });724 };725 }],726 link: function (scope, element, attrs) {727 scope.configOption = attrs.config;728 scope.noenter = attrs.noenter;729 }730 };731 return readCardObject;...

Full Screen

Full Screen

read-user-info.js

Source:read-user-info.js Github

copy

Full Screen

1const t = require('tap')2let readOpts = null3let readResult = null4const read = (opts, cb) => {5 readOpts = opts6 return cb(null, readResult)7}8const npmlog = {9 clearProgress: () => {},10 showProgress: () => {},11}12const npmUserValidate = {13 username: (username) => {14 if (username === 'invalid')15 return new Error('invalid username')16 return null17 },18 email: (email) => {19 if (email.startsWith('invalid'))20 return new Error('invalid email')21 return null22 },23}24const readUserInfo = t.mock('../../../lib/utils/read-user-info.js', {25 read,26 npmlog,27 'npm-user-validate': npmUserValidate,28})29t.test('otp', async (t) => {30 readResult = '1234'31 t.teardown(() => {32 readResult = null33 readOpts = null34 })35 const result = await readUserInfo.otp()36 t.equal(result, '1234', 'received the otp')37})38t.test('password', async (t) => {39 readResult = 'password'40 t.teardown(() => {41 readResult = null42 readOpts = null43 })44 const result = await readUserInfo.password()45 t.equal(result, 'password', 'received the password')46 t.match(readOpts, {47 silent: true,48 }, 'got the correct options')49})50t.test('username', async (t) => {51 readResult = 'username'52 t.teardown(() => {53 readResult = null54 readOpts = null55 })56 const result = await readUserInfo.username()57 t.equal(result, 'username', 'received the username')58})59t.test('username - invalid warns and retries', async (t) => {60 readResult = 'invalid'61 t.teardown(() => {62 readResult = null63 readOpts = null64 })65 let logMsg66 const log = {67 warn: (msg) => logMsg = msg,68 }69 const pResult = readUserInfo.username(null, null, { log })70 // have to swap it to a valid username after execution starts71 // or it will loop forever72 readResult = 'valid'73 const result = await pResult74 t.equal(result, 'valid', 'received the username')75 t.equal(logMsg, 'invalid username')76})77t.test('email', async (t) => {78 readResult = 'foo@bar.baz'79 t.teardown(() => {80 readResult = null81 readOpts = null82 })83 const result = await readUserInfo.email()84 t.equal(result, 'foo@bar.baz', 'received the email')85})86t.test('email - invalid warns and retries', async (t) => {87 readResult = 'invalid@bar.baz'88 t.teardown(() => {89 readResult = null90 readOpts = null91 })92 let logMsg93 const log = {94 warn: (msg) => logMsg = msg,95 }96 const pResult = readUserInfo.email(null, null, { log })97 readResult = 'foo@bar.baz'98 const result = await pResult99 t.equal(result, 'foo@bar.baz', 'received the email')100 t.equal(logMsg, 'invalid email')...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt.js');2var wptObj = new wpt('API_KEY');3wptObj.readResult('testId', function(err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data);8 }9});10var request = require('request');11var wpt = function(api_key) {12 this.api_key = api_key;13};14wpt.prototype.readResult = function(testId, callback) {15 request.get(url, function(err, res, body) {16 if (err) {17 callback(err, null);18 } else {19 callback(null, body);20 }21 });22};23module.exports = wpt;24var wpt = require('./wpt.js');25var wptObj = new wpt('API_KEY');26wptObj.readResult('testId', function(err, data) {27 if (err) {28 console.log(err);29 } else {30 console.log(data);31 }32});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt')2var options = {3}4wpt.runTest(options, function(err, data) {5 if (err) {6 console.log(err)7 } else {8 console.log(data)9 wpt.readResult(data.data.testId, function(err, data) {10 if (err) {11 console.log(err)12 } else {13 console.log(data)14 }15 })16 }17})

Full Screen

Using AI Code Generation

copy

Full Screen

1var fs = require('fs');2var wpt = {3 readResult: function () {4 var result = fs.readFileSync('result.json', 'utf8');5 return result;6 }7};8module.exports = wpt;

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt.js');2var wpt = new wpt('API_KEY');3var result = wpt.readResult(url, function(result){4 console.log(result);5});6var wpt = require('webpagetest');7var wpt = new wpt('API_KEY');8var result = wpt.readResult(url, function(result){9 console.log(result);10});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2 if (err) {3 console.log(err);4 }5 else {6 console.log(data);7 }8});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful