2019-03-22 13:56:11 +08:00
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
|
using Cmdjy.ws;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using CmdjyTests.HisServices;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Cmdjy.Dal;
|
|
|
|
|
using System.Reflection;
|
2019-03-25 16:32:58 +08:00
|
|
|
|
using HisInterfaceModels;
|
2019-03-22 13:56:11 +08:00
|
|
|
|
|
|
|
|
|
namespace Cmdjy.ws.Tests
|
|
|
|
|
{
|
|
|
|
|
[TestClass()]
|
|
|
|
|
public class HisInterfaceTests
|
|
|
|
|
{
|
|
|
|
|
[TestMethod()]
|
|
|
|
|
public void PostPrescriptionInfoTest() {
|
|
|
|
|
var service = new HisInterfaceSoapClient();
|
2019-03-25 16:32:58 +08:00
|
|
|
|
var newpres = new HisPrescriptionInfo {
|
2019-03-22 13:56:11 +08:00
|
|
|
|
Area = "Area",Bed = "Bed",CardNo = "CardNo",CompanyCode = "CompanyCode",
|
|
|
|
|
CompanyName = "CompanyName",DepName = "DepName",Diagnosis = "Diagnosis",District = "District",
|
|
|
|
|
DoctorName = "DoctorName",DrugCount = "DrugCount",HosName = "HosName",HosNo = "HosNo",InvoiceNo = "InvoiceNo",
|
|
|
|
|
OpDatatime = "OpDatatime",OpType = "OpType",OpUser = "OpUser",PatientAge = "PatientAge",
|
|
|
|
|
PatientBrithday = "PatientBrithday",PatientMobile = "PatientMobile",PatientName = "PatientName",
|
|
|
|
|
PatientNo = "PatientNo",PatientPhone = "PatientPhone",PatientSex = "PatientSex",PostAddress = "PostAddress",
|
|
|
|
|
PostDatatime = "PostDatatime",PrescriptionDatatime = "PrescriptionDatatime",PrescriptionNo = "PrescriptionNo",
|
|
|
|
|
RawRecordId = "RawRecordId",Remark = "Remark",Sffyxh = "Sffyxh",Sfxh = 1,TakeBack = "TakeBack",
|
2019-03-25 16:32:58 +08:00
|
|
|
|
Type = PrescriptionType.Order,Usage = "Usage",UseCount = "UseCount",Zlh = "Zlh",
|
2019-03-22 13:56:11 +08:00
|
|
|
|
};
|
2019-03-25 16:32:58 +08:00
|
|
|
|
var msg = JsonConvert.SerializeObject(newpres);
|
|
|
|
|
var result = service.PostPrescription(msg);
|
2019-03-22 13:56:11 +08:00
|
|
|
|
Console.WriteLine($"result:{result}");
|
|
|
|
|
var rObj = JsonConvert.DeserializeObject<HisPrescriptionResult>(result);
|
|
|
|
|
Assert.IsTrue(rObj.Code == ResultCode.Success);
|
|
|
|
|
using(var db = new DjyDbContext()) {
|
|
|
|
|
var qu = db.PrescriptionInfos.Where(m => m.Id.ToString() == rObj.PrescriptionId).ToList();
|
|
|
|
|
Assert.IsTrue(qu.Any());
|
|
|
|
|
Assert.IsTrue(qu.Count == 1);
|
|
|
|
|
var fst = qu.First();
|
|
|
|
|
foreach(PropertyInfo p in newpres.GetType().GetProperties()) {
|
|
|
|
|
var dbp = fst.GetType().GetProperties().Where(m => m.Name == p.Name);
|
2019-03-25 16:32:58 +08:00
|
|
|
|
Assert.IsTrue(dbp.Any(),$"不包含属性{p.Name}");
|
2019-03-22 13:56:11 +08:00
|
|
|
|
var lv = p.GetValue(newpres);
|
|
|
|
|
var dbv = fst.GetType().GetProperties().First(m => m.Name == p.Name).GetValue(fst);
|
2019-03-25 16:32:58 +08:00
|
|
|
|
var bj =
|
|
|
|
|
p.Name == "Type" ? dbv.ToString() == lv.ToString() :
|
|
|
|
|
dbv.Equals(lv);
|
|
|
|
|
Assert.IsTrue(bj,$"属性比较失败:{p.Name}:{dbv}:{lv}");
|
2019-03-22 13:56:11 +08:00
|
|
|
|
}
|
|
|
|
|
foreach(var item in qu) {
|
|
|
|
|
db.Entry(item).State = System.Data.Entity.EntityState.Deleted;
|
|
|
|
|
db.SaveChanges();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|